﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetfractionHub.LocalMachine.BotCommands
{
    public class CommandMessage
    {
        private string _name;
        private Dictionary<string, bool> _booleanArguments;
        private Dictionary<string, string> _stringArguments;
        private List<string> _unnamedArguments;

        public CommandMessage()
        {
            _booleanArguments = new Dictionary<string, bool>();
            _stringArguments = new Dictionary<string, string>();
            _unnamedArguments = new List<string>();
        }

        public Dictionary<string, bool> BooleanArguments
        {
            get { return _booleanArguments; }
            set { _booleanArguments = value; }
        }

        public Dictionary<string, string> StringArguments
        {
            get { return _stringArguments; }
            set { _stringArguments = value; }
        }

        public List<string> UnnamedArguments
        {
            get { return _unnamedArguments; }
            set { _unnamedArguments = value; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public int ArgumentsCount
        {
            get { return _booleanArguments.Count + _stringArguments.Count + _unnamedArguments.Count; }
        }

        public override string ToString()
        {
            StringBuilder output = new StringBuilder();
            output.AppendFormat("Command Name: {0}\n", _name);
            output.Append("Boolean Arguments: ");
            foreach (KeyValuePair<string, bool> arg in _booleanArguments)
            {
                output.Append(arg.Key);
                output.Append(", ");
            }
            output.Remove(output.Length - 2, 2);
            output.AppendLine();

            output.Append("String Arguments: ");
            foreach (KeyValuePair<string, string> arg in _stringArguments)
            {
                output.Append(arg.Key);
                output.Append(":");
                output.Append(arg.Value);
                output.Append(", ");
            }
            output.Remove(output.Length - 2, 2);
            output.AppendLine();

            output.Append("Unnamed Arguments: ");
            foreach (string arg in _unnamedArguments)
            {
                output.Append(arg);
                output.Append(", ");
            }
            output.Remove(output.Length - 2, 2);
            output.AppendLine();

            return output.ToString();
        }
    }
}